{% extends 'base.htm' %}
{% from 'macros.htm' import name_fmt, find_notifs, addr_fmt, make_plural, special_fmt, map_image, prim_category, category_fmt, checkin_badge_fmt %}
{% set title = 'Checked In' %}

{% block body %}
    {% call(msg) find_notifs(notif, 'message') %}
	<p>{{ msg.message|e }}
    {% endcall %}

    {% set venue = checkin.venue %}
    {% if venue %}
	<p><a class="button" href="/venue?vid={{ venue.id|urlencode }}">{{ venue.name|e }}</a><br>
	{{ addr_fmt(venue) }}
	{% set location = venue.location %}
	{% if location.lat and location.lng %}
	    {{ map_image(location.lat, location.lng) }}
	{% endif %}

	{% call(cat) prim_category(venue) %}
	    {{ category_fmt(cat) }}
	{% endcall %}
    {% endif %}

    {% call(mayor) find_notifs(notif, 'mayorship') %}
	{% set user = mayor.user %}
	{% if user %}
	    <p><img src="{{ user.photo.prefix|e ~ '36x36' ~ user.photo.suffix|e }}" class="usericon, lefticon" alt="">{{ mayor.message|e }}
	    <br style="clear:both">
	{% else %}
	    <p>{{ mayor.message|e }}
	{% endif %}
    {% endcall %}

    {{ checkin_badge_fmt(checkin) }}

    {% set score = checkin.score %}
    {% if score and score.scores %}
	{% for s in score.scores %}
	    <p><img src="{{ s.icon|e }}" class="lefticon">
	    {{ make_plural(s.points, 'point') }}: {{ s.message|e }}
	    <br style="clear:both">
	{% endfor %}
    {% endif %}

    {% call(special) find_notifs(notif, 'special') %}
	<p>{{ special_fmt(special.special) }}
    {% endcall %}

    {% call(leaderboard) find_notifs(notif, 'leaderboard') %}
	{% for leader in leaderboard.leaderboard %}
	    {% set user = leader.user %}
	    {% set scores = leader.scores %}
	    <p><img src="{{ user.photo.prefix|e ~ '36x36' ~ user.photo.suffix|e }}" class="usericon, lefticon" alt=""> #{{ leader.rank|e }}: {{ name_fmt(user, button=false) }}<br>
	    {{ scores.recent|e }} points, {{ scores.checkinsCount|e }} checkins, {{ scores.max|e }} max<br style="clear:both">
	{% endfor %}
	<p>{{ leaderboard.message|e }}
    {% endcall %}
{% endblock %}

{# vim:set ft=htmldjango tw=0: #}
